#include "../source/server.hpp"

void OnConnected(const PtrConnection &conn)
{
    DBG_LOG("new connection : %ld", conn->Id());
}

void OnClosed(const PtrConnection &conn)
{
    DBG_LOG("close connection : %ld", conn->Id());
}
void OnMessage(const PtrConnection &conn, Buffer *buf)
{
    DBG_LOG("%s", buf->ReadPosition());
    buf->MoveReadOffset(buf->ReadableSize());
    std::string str = "nightcord";
    conn->Send(str.c_str(), str.size());
}

int main()
{
    TcpServer server(21000);
    server.SetThreadCount(2);
    server.SetEnableInactiveRelease(10);
    server.SetConnectedCallback(OnConnected);
    server.SetMessageCallback(OnMessage);
    server.SetClosedCallback(OnClosed);
    server.Start();

    return 0;
}